package everyday;

import java.util.HashMap;
import java.util.Map;

public class T2399 {
    public boolean checkDistances(String s, int[] distance) {
        Map<Integer,Integer> map=new HashMap<>();
        for (int i = 0; i <s.length() ; i++) {
            int c=s.charAt(i)-'a';
            if (map.containsKey(c)){
                if(i-map.get(c)-1!=distance[c])return false;
            }else {
                map.put(c,i);
            }
        }
        return true;
    }
}
